package org.myhomework.servelet;

import org.myhomework.constant.Constants;
import org.myhomework.dao.TeacherDao;
import org.myhomework.entity.Teacher;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

public class TeacherPageServlet extends HttpServlet {
    @Override
    public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Integer userId = (Integer) req.getSession().getAttribute(Constants.USER_ID_ATTRIBUTE);
        List<Teacher> teacherList = TeacherDao.getTeacherList(userId);
        req.setAttribute("teacherList", teacherList);
        req.getRequestDispatcher("/teacher.jsp").forward(req, resp);
    }


}
